﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OauthProvider
{
    public class ConsumerValidationInspector : IContextInspector
    {
        readonly IConsumerStore _consumerStore;

        public ConsumerValidationInspector(IConsumerStore consumerStore)
        {
            if (consumerStore == null) throw new ArgumentNullException("consumerStore");
            _consumerStore = consumerStore;
        }

        public void InspectContext(ProviderPhase phase, IOAuthContext context)
        {
            if (!_consumerStore.IsConsumer(context))
            {
                throw Error.UnknownConsumerKey(context);
            }
        }
    }
}
